package edu.must.uh.util;

import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
public class CellFormat {

    public static final WritableCellFormat getCellFormat() throws Exception{
        //表格式樣
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        return cellFormat;
    }
    
       public static final WritableCellFormat getRedCellFormat() throws Exception{
            //表格式樣
           
           WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 12);            
            cellFont.setColour(jxl.format.Colour.RED);
           WritableCellFormat cellFormat = new WritableCellFormat(cellFont);    
           // cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
           // cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
          //  cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
            return cellFormat;
        }
    
    public static final WritableCellFormat getVerticalCellFormat() throws Exception{
        //表格式樣
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        return cellFormat;
    }
    
    public static final WritableCellFormat getCellFormatB() throws Exception{
            //表格式樣
          WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 12);
          cellFont.setBoldStyle(WritableFont.BOLD);
            WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
            cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
            cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
            cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
            return cellFormat;
        }
    public static final WritableCellFormat getNCellFormat() throws Exception{
        //表格式樣
        WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 12);
        WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        return cellFormat;
    }
    public static final WritableCellFormat getNCellFormatRight() throws Exception{
        //表格式樣
        WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 12);
        WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
        cellFormat.setAlignment(jxl.format.Alignment.RIGHT);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        return cellFormat;
    }
    public static final WritableCellFormat getNCellFormatNoBorder() throws Exception{
        //表格式樣
        WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 14);
        WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
        cellFormat.setAlignment(jxl.format.Alignment.LEFT);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.NONE, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        return cellFormat;
    } 
    public static final WritableCellFormat getNCellFormatLeftBold() throws Exception{
        //表格式樣
        WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 12, WritableFont.BOLD, false);
        WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
        cellFormat.setAlignment(jxl.format.Alignment.LEFT);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        return cellFormat;
    }
    public static final WritableCellFormat getNCellFormatRightBold() throws Exception{
        //表格式樣
        WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 12, WritableFont.BOLD, false);
        WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
        cellFormat.setAlignment(jxl.format.Alignment.RIGHT);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        return cellFormat;
    }
    public static final WritableCellFormat getNCellFormatDoubleBottomline() throws Exception{
        //表格式樣
        WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 16);
        WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.BOTTOM, jxl.format.BorderLineStyle.DOUBLE, jxl.format.Colour.BLACK);
        return cellFormat;
    }
    public static final WritableCellFormat getNCellFormatThickBottomline() throws Exception{
        WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 16);
        WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.BOTTOM, jxl.format.BorderLineStyle.THICK, jxl.format.Colour.BLACK);
        return cellFormat;
    }
    public static final WritableCellFormat getNHeaderFormat() throws Exception{
        //表格式樣
        WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 12);
        WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        cellFormat.setBackground(jxl.format.Colour.YELLOW);
        return cellFormat;
    }
    public static final WritableCellFormat getNCellFormatNOCenter() throws Exception{
        //表格式樣
        WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 12);
        WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        return cellFormat;
    }
    public static final WritableCellFormat getTitleFormat() throws Exception{
        //表格式樣
        WritableCellFormat cellFormat = new WritableCellFormat();
        //cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        return cellFormat;
    }
  public static final WritableCellFormat getHeaderFormat12() throws Exception{
        //表格式樣
        WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 12);
        cellFont.setBoldStyle(WritableFont.BOLD);
        WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        return cellFormat;
    }
    public static final WritableCellFormat getHeaderFormat() throws Exception{
        //表格式樣
        WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 24);
        cellFont.setBoldStyle(WritableFont.BOLD);
        WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        return cellFormat;
    }
    public static final WritableCellFormat getHeaderSmallFormat() throws Exception{
        //表格式樣
        WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 12);
        cellFont.setBoldStyle(WritableFont.BOLD);
        WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.BOTTOM);
        return cellFormat;
    }
    public static final WritableCellFormat getImformatFormat() throws Exception{
        //表格式樣
        WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), 12);
        WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        return cellFormat;
    }   
    public static final WritableCellFormat getCellRightFormat() throws Exception{
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setAlignment(jxl.format.Alignment.RIGHT);
        return cellFormat;
    }
    
    public static final WritableCellFormat getCellLeftFormat() throws Exception{
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setAlignment(jxl.format.Alignment.LEFT);
        return cellFormat;
    }
    
    public static final WritableCellFormat getBottomNoBorderFormat() throws Exception{
        //表格式樣
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setWrap(true);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.TOP, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        cellFormat.setBorder(jxl.format.Border.LEFT, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        cellFormat.setBorder(jxl.format.Border.RIGHT, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        return cellFormat;
    }
    public static final WritableCellFormat getTopNoBorderFormat() throws Exception{
        //表格式樣
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setWrap(true);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.BOTTOM, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        cellFormat.setBorder(jxl.format.Border.LEFT, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        cellFormat.setBorder(jxl.format.Border.RIGHT, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        return cellFormat;
    }
    public static final WritableCellFormat getVerticalNoBorderFormat() throws Exception{
        //表格式樣
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setWrap(true);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.LEFT, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        cellFormat.setBorder(jxl.format.Border.RIGHT, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        return cellFormat;
    }
    public static final WritableCellFormat getWrapCellFormat() throws Exception{
        //表格式樣
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setWrap(true);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        return cellFormat;
    }
    public static final WritableCellFormat getTopThickBorderFormat() throws Exception{
        //表格式樣
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setWrap(true);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        cellFormat.setBorder(jxl.format.Border.TOP, jxl.format.BorderLineStyle.DOTTED, jxl.format.Colour.BLACK);
        cellFormat.setBorder(jxl.format.Border.BOTTOM, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        cellFormat.setBorder(jxl.format.Border.LEFT, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        cellFormat.setBorder(jxl.format.Border.RIGHT, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK);
        return cellFormat;
    }
    
    
}
